{include('Layout/header')}
<div class="row row-bgcolor">
    <div class='col-md-12 content-title'>
        <h3>文章列表</h3>
    </div>
    <div class='col-md-10 content col-md-offset-1'>
        <div class='select-border'>
            <form class="form-inline" action="{\Rexzy::url('admin/artlist')}" method="post">
                <div class="form-group">
                  <label class="sr-only" for="keyword">keyword</label>
                  <input type="text" class="form-control input-sm" id="keyword" placeholder="关键字" name='keyword'>
                </div>
                <div class="form-group">
                  <select class="form-control input-sm" name="sort">
                    <option value="0">所有分类</option>
                    {php} 
                        function sortChoice( $id, $artsort ) {
                            $sorts = $artsort->selectAll( 'sortid, name, parent, children', "where parent = $id" );
                            foreach ( $sorts as $key => $value ) {
                            echo "<option value='" . $value['sortid'] . "'>" . $value['name'] . "</option>";
                                if ( $value['children'] > 0 ) {
                                    sortChoice( $value['sortid'], $artsort );
                                }
                            }
                        }
                        sortChoice( 0, $artsort );
                    {/php}
                  </select>
                </div>
                <button type="submit" class="btn btn-default input-sm art-list-search">筛选</button>
            </form>
        </div>
        <div class='table-list'>
            <table class="table table-hover">
                <colgroup>
                    <col width="5%">
                    <col width="5%">
                    <col width="35%">
                    <col width>
                    <col width="25%">
                    <col width="15%">
                </colgroup>
                <thead>
                    <tr>
                        <th></th>
                        <th></th>
                        <th>标题</th>
                        <th>作者</th>
                        <th>分类</th>
                        <th>日期</th>
                    </tr>
                </thead>
                <tbody>
                    {php}
                    if( count( $arts ) == 0 ){
                        echo "<td colspan='6'><h6 class='list-none'>没有任何文章</h6></td>";
                    } else {
                        foreach( $arts as $key => $val ){
                            echo "<tr><td><input type='checkbox' class='select-box' 
                             value='" . $val['artid'] . "'/></td><td><a class='
                            line-btn comment-btn' href='#'><span class='num-border'>" . $val['comment']
                            . "</span></a></td><td><a class='line-btn' href='" . $editUrl . "?artid=" . 
                           $val['artid'] . "'>" . $val['title'] . "</a></td><td>
                           <a href='$listUrl?author=" . $val['author'] . "' class=
                          'line-btn'>" . $val['author'] . "</td><td>" . $val['sortmesg'] 
                           . "</td><td>" . date( 'Y-m-d', $val['date'] ) . "</td>";
                        }
                    }
                    {/php}
                </tbody>
            </table>
        </div>
        <div class="paging-border">
            <div class='handle-user'>
                <label class="checkbox-inline">
                    <input type='checkbox' id='select_all' />选择全部
                </label>
                <button type="submit" id="art_delete_btn">删除选中项</button>
                {if $index != true}
                    echo "<a href='" . $listUrl . "' class='return-artlist'>返回列表首页</a>";
                {/if}
            </div>
            <nav>
                <ul class="pagination">
                    {php}
                        $this->page->paging( $total, $rang = 5, $page, $length, $listUrl, $condition );
                    {/php}
                </ul>
            </nav>
        </div>
    </div>
</div>

<script>
    $(function() {
        var warningMesg = "确定删除选中文章？";
        var handleUrl = url( 'admin/artdelete');

        var goUrl = url( 'admin/artlist' );
        deleteList( '#art_delete_btn', warningMesg, handleUrl, goUrl )
    });
</script>

{include('Layout/footer')}